<?php 
	require('include/top.php');

	$db = Database::getInstance();
	if (!empty($_GET['id'])){
		$article_id = $_GET['id'];
		$article = new Article($article_id);
	
		$article_titre = $article->art_title;
		$article_content = $article->art_content;
		
		
	}
	
	

	
	
	if (!empty($_POST['titre'])){
		$link = mysql_connect(DB_HOST, DB_USER, DB_PWD);
		
		$titre_up = $_POST['titre'];
		$content_up = $_POST['content'];
		$id = $_POST['id'];
		
		$sql = 'UPDATE blog_article SET art_title = "' . $titre_up . '" , art_content = "'.$content_up.'" WHERE art_id= "'.$id.'"';
		echo($sql);
		$db->exec($sql);
	
		include('templates/header.tpl.php');
		include('templates/modifyArticle.tpl.php');
		include('templates/footer.tpl.php');
	
		mysql_close($link);
		header("Location:article.php?id=".$id."");
	}

	else{

		include('templates/header.tpl.php');
		include('templates/modifyArticle.tpl.php');
		include('templates/footer.tpl.php');
	}
 ?> 